<!--本文件由FirstUI授权予关赛川（手机号： 1 5  60  05 1  520 5，身份证尾号：22 6  5 1 9）专用，请尊重知识产权，勿私下传播，违者追究法律责任。-->
<template>
	<view class="confirmPayList">
		<view class="explain-cont">
			<view class="cont1">
				支付剩余时间 30:00
			</view>
			<view class="cont2">
				¥128.00
			</view>
			<view class="cont3">
				¥228.00
			</view>
			<view class="cont4">
				王婆大虾双人餐
			</view>
		</view>
		<!-- 微信支付 -->
		<view class="packBusiness marin25">
			<fui-radio-group name="radio" v-model="val" @change="payChange">
				<view class="fui-list__item">
					<fui-label>
						<view class="fui-align__center">
							<fui-radio value="1" checked></fui-radio>
							<image class="pay-img" :src="baseOssUrl + 'icon/weixin.png' " mode=""></image>
							<text class="fui-text">微信支付</text>
						</view>
					</fui-label>
				</view>
			</fui-radio-group>
		</view>

		<!-- 确认支付订单按钮 -->
		<view class="fixedBtn">
			<fui-button background="#35743D" radius='50rpx' class="addButn" width="95%" @click='confirmPayment' height="72rpx"
			 size='28'>确认支付</fui-button>
		</view>
		<!-- 支付成功弹窗 -->
		<fui-bottom-popup :show="payShow" @close="payShow = false">
			<view class="fui-scroll__wrap">
				<view class="fui-header">
					<text>支付成功</text>
					<view class="fui-icon__close" @tap="closePopup">
						<fui-icon name="close" :size="48"></fui-icon>
					</view>
				</view>
				<view class="fui-money">
					¥128.00
				</view>
				<!-- 支付红包 -->
				<view class="payPacket marin25">
					<view class="pay-p1">
						酒店在线支付红包
					</view>
					<view class="pay-p2">
						¥128.00
					</view>
					<view class="pay-p3" @click="getRedPacket">
						领取
					</view>
				</view>
			</view>
		</fui-bottom-popup>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	import {
		baseOssUrl
	} from '@/common/settings';
	export default {
		//登录状态
		computed: mapState(['isLogin']),
		data() {
			return {
				baseOssUrl: baseOssUrl,
				payShow: true
			}
		},
		onLoad() {
			// if (!this.isLogin) {
			// 	uni.navigateTo({
			// 		url: '../login/index'
			// 	})
			// }
		},
		methods: {
			...mapMutations(['login', 'logout']),
			// 领取红包页面
			getRedPacket(){
				uni.navigateTo({
					url:'/pages/redPacket/index'
				})
			},
			// 确认支付
			confirmPayment() {
				this.$http.post(this.$httpApi.ordeWxPay).then(res => {
					if (res.code == 0) {
						console.log("pay", res)
						uni.requestPayment({
							provider: 'wxpay',
							timeStamp: res.response.timeStamp,
							nonceStr: res.response.nonceStr,
							package: 'prepay_id=' + res.response.prepayId,
							signType: 'MD5',
							paySign: res.response.paySign,
							success: res => {
								this.payShow = true
								console.log('success:' + JSON.stringify(res));
							},
							fail: err => {
								console.log('fail:' + JSON.stringify(err));
							}
						});
					}
				})
			},
			//调用此方法显示底部弹出层
			showPopup(type) {
				this.payShow = true
			},
			closePopup(type) {
				this.payShow = false
				console.log("type1",type)
				uni.navigateTo({
					url: '/pages/foodBuySuccess/index'
				})
				console.log("type2",type)
			},

			payChange(e) {
				console.log("e", e)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.confirmPayList {
		height: 100%;

		// 文字说明
		.explain-cont {
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			padding: 74rpx 0;
			color: #969696;

			.cont1 {
				font-size: 24rpx;
				margin-bottom: 20rpx;
			}

			.cont2 {
				color: #D93C3C;
				font-size: 40rpx;
			}

			.cont3 {
				margin: 16rpx 0;
			}
		}

		.packBusiness {
			margin-top: 26rpx;
			background-color: #FFFFFF;
			border-radius: 16rpx;
			margin-bottom: 30rpx;
			padding: 24rpx;
			font-size: 28rpx;

			.fui-list__item {
				// display: flex;
				// flex-direction: column;
				padding: 20rpx 0;

				.pay-img {
					margin: 0 20rpx;
					width: 40rpx;
					height: 39rpx;
				}
			}
		}

		// 新增入住人信息
		.fixedBtn {
			position: fixed;
			bottom: 90rpx;
			width: 100%;

			.addButn {
				display: flex;
				justify-content: center;

			}

			.orderBtn {
				font-size: 28rpx;
				margin-left: 15rpx;
			}
		}

		// 确认支付弹窗
		.fui-scroll__wrap {
			.fui-header {
				display: flex;
				justify-content: center;
				position: relative;
				margin-top: 32rpx;

				.fui-icon__close {
					position: absolute;
					right: 10rpx;
				}
			}

			.fui-money {
				display: flex;
				justify-content: center;
				font-size: 40rpx;
				color: #D93C3C;
				margin: 50rpx 0 40rpx;
			}
			.payPacket{
				display: flex;
				justify-content: center;
				flex-direction: column;
				align-items: center;
				padding:46rpx 0 ;
				border: 1px solid #1D1D1D;
				margin-bottom: 80rpx;
				.pay-p1{
					font-size: 30rpx;
				}
				.pay-p2{
					font-size: 40rpx;
					margin:20rpx  0;
				}
				.pay-p3{
					font-size: 26rpx;
					padding:3rpx 20rpx;
					border: 1px solid #1D1D1D;
				}
			}

		}
	}
</style>
